/*
ID: guoxu1
PROG: lamps
LANG: C++
*/
#include <fstream>
using namespace std;

const int reverses[] = { 0xf, 0xa, 0x5, 0x9 };
const int classes[] = {3,2,1,0,1,2,3,2,1,0,1,2};

inline int getclass( int n )
{
	return 1 << classes[ (n - 1) % 12 ];
}

inline int getbitcount( int n )
{
	int c = 0;
	while( n > 0 )
	{
		n &= n - 1;
		c++;
	}
	return c;
}

#define cin fin
#define cout fout

int main()
{
	ifstream fin( "lamps.in" );
	ofstream fout( "lamps.out" );

	unsigned int ON = 0;
	unsigned int OFF = 0;

	int N = 0, C = 0;
	cin >> N >> C;
	int t = 0;
	while( cin >> t, t != -1 )
	{
		ON |= getclass( t );
	}
	while( cin >> t, t != -1 )
	{
		OFF |= getclass( t );
	}
	if( (ON & OFF) != 0 )
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	bool solt[16] = {false};

	for( int i = 0; i < 16; i++ )
	{
		int c = getbitcount(i);
		if( c % 2 != C % 2 || c > C ) continue;

		int k = 0;
		for( int j = 0; j < 4; j++ )
		{
			if( ( i & ( 1 << j ) ) != 0 )
			{
				k ^= reverses[j];
			}
		}
		solt[k] = true;
	}

	bool impossible = true;
	for( int i = 15; i >= 0; i-- )
	{
		if( !solt[i] ) continue;

		if( (~i & ON) != ON ) continue;
		if( (i & OFF) != OFF ) continue;

		for( int j = 1; j <= N; j++ )
		{
			cout << ((i & getclass(j)) > 0 ? 0 : 1);
		}
		cout << endl;
		impossible = false;
	}
	if( impossible ) cout << "IMPOSSIBLE" << endl;

	return 0;
}